﻿using System.Collections.Generic;

namespace Comdiv.QWeb.Utils.LogicalExpressionLanguage {
	public class DictionaryTermSource : LogicTermSource {
		private readonly IDictionary<string, string> all;

		public DictionaryTermSource(IDictionary<string, string> dict) {
			all = dict;
		}

		public override string value(string name) {
			return all.ContainsKey(name) ? all[name] : "";
		}

		public override IDictionary<string, string> getall() {
			return all;
		}

		public override bool get(string name) {
			return all.ContainsKey(name);
		}

		public override bool equal(string name, string value) {
			return all.ContainsKey(name) && Equals(value, all[name]);
		}
	}
}